package com.gsy.reflect;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ResourceBundle;

public class Test {
    public static void main(String[] args) throws Exception {



        ResourceBundle resourceBundle = ResourceBundle.getBundle("re");
        Class clazz = Class.forName(resourceBundle.getString("className"));
        Constructor constructor = clazz.getDeclaredConstructor();
        constructor.setAccessible(true);
        Method method1 = clazz.getDeclaredMethod(resourceBundle.getString("classMethod1"));
        method1.setAccessible(true);
        Method method2 = clazz.getDeclaredMethod(resourceBundle.getString("classMethod2"),String.class);
        method2.setAccessible(true);
        Field field = clazz.getDeclaredField(resourceBundle.getString("classField"));
        field.setAccessible(true);
        Object object = constructor.newInstance();
        if (field.getType() == String.class){
            field.set(object,"hhh");
        }else {
            field.setInt(object,18);
        }
        method1.invoke(object);
        method2.invoke(object,"asaa");

    }
}
